#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5+10;

typedef long long ll;

struct AD{
	int l,r,num;
	bool operator < (const AD &b)const{
		return l == b.l ? r > b.r : l < b.l;
	}
}ad[MAXN],tmp[MAXN];

int n,m,tot,x,y;
ll ans;

int find(int x){
	int l = 1,r = tot;
	while(l <= r){
		int mid = l+r>>1;
		if(ad[mid].l < x) l = mid+1;
		else r = mid-1;
	}
	return l;
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= n;i++) scanf("%d %d",&tmp[i].l,&tmp[i].r),tmp[i].num = i;
	sort(tmp+1,tmp+n+1);
	ad[1] = tmp[1];tot = 1;
	for(int i = 2;i <= n;i++){
		if(tmp[i].r > ad[tot].r){
			ad[++tot] = tmp[i];
		}
	}
	for(int i = 1;i <= m;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		int pos = find(a)-1;
		for(;ad[pos].l <= b && pos <= tot;pos++){
			ll t = (ll)(min(ad[pos].r,b) - max(ad[pos].l,a))*c;
			if(t > ans) ans = t,x = ad[pos].num,y = i;
		}
	}
	printf("%lld\n",ans);
	if(ans) printf("%d %d\n",x,y);
	return 0;
}
